# Maintainer: kpcyrd <kpcyrd[at]archlinux[dot]org>
# Contributor: Julien (jvoisin) Voisin <julien.voisin+snuffleupagus@dustri.org>

pkgname=php-snuffleupagus
_pkgname=snuffleupagus
pkgver=0.9.0
pkgrel=2
pkgdesc="Security module for PHP"
url='https://snuffleupagus.readthedocs.io/'
arch=('loong64' 'x86_64')
license=('LGPL3')
depends=('php')
backup=('etc/php/conf.d/snuffleupagus.ini'
        'etc/php/conf.d/snuffleupagus.rules')
source=(https://github.com/jvoisin/${_pkgname}/archive/v${pkgver}/${_pkgname}-${pkgver}.tar.gz)
sha256sums=('36c99dd9540444ab6c931c687255522dac6705275cdc291b4e25a1d416b7a42e')
b2sums=('c01246d7bc3cf248c2cdceb22a8b720ccaccf52498b3f02a20a2083190aadccb802a109a51509caae229b3625ff09174a173be3a996360b4576e87fefad3be21')

prepare() {
  cd ${_pkgname}-${pkgver}

  # tests are incompatible with PHP 8.1
  rm src/tests/{disable_function/disabled_functions_include_once,disable_function/disabled_functions_include_simulation,disable_function/disabled_functions_register_tick_function,disable_function/disabled_functions_require,disable_function/disabled_functions_require_once,disable_function/disabled_functions_require_simulation,strict_mode/strict_mode_enabled,stream_wrapper/stream_wrapper}.phpt

  # tests are incompatible with PHP 8.2
  rm src/tests/{deny_writable/deny_writable_execution,deny_writable/deny_writable_execution_simulation,disable_function/disabled_functions_require_allow}.phpt
}

build() {
  cd ${_pkgname}-${pkgver}/src
  phpize
  ./configure --prefix=/usr --enable-"${_pkgname}"
  make
}

check() {
  cd ${_pkgname}-${pkgver}/src
  NO_INTERACTION=1 REPORT_EXIT_STATUS=1 make test
}

package() {
  cd ${_pkgname}-${pkgver}
  make -C src INSTALL_ROOT="${pkgdir}" install
  install -D -m644 "config/default_php8.rules" "${pkgdir}/etc/php/conf.d/${_pkgname}.rules"
  install -D -m644 "config/${_pkgname}.ini" "${pkgdir}/etc/php/conf.d/${_pkgname}.ini"
}

# vim: ts=2 sw=2 et:
